﻿@inject IStringLocalizer<DropdownNormal> Localizer

<Dropdown TValue="string" Items="Items" OnSelectedItemChanged="@ShowMessage" Color="Color.Secondary" />
<BlockLogger @ref="Trace" class="mt-3" />

@code {
    [NotNull]
    private BlockLogger? Trace { get; set; }

    private List<SelectedItem> Items { get; set; } = new List<SelectedItem> { };

    /// <summary>
    /// ShowMessage
    /// </summary>
    /// <param name="e"></param>
    /// <returns></returns>
    private Task ShowMessage(SelectedItem e)
    {
        Trace.Log($"Dropdown Item Clicked: Value={e.Value} Text={e.Text}");
        return Task.CompletedTask;
    }

    /// <summary>
    /// OnInitialized
    /// </summary>
    protected override void OnInitialized()
    {
        base.OnInitialized();

        Items = new List<SelectedItem>
        {
            new SelectedItem{ Text=Localizer["Item1"], Value="0"},
            new SelectedItem{ Text=Localizer["Item2"], Value="1"},
            new SelectedItem{ Text=Localizer["Item3"], Value="2"},
        };
    }
}
